import request from '@/utils/request';

/**
 * 报销项目列表
 */
export async function pageOaProject(params) {
  const res = await request.post('/oa_cost_project/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除报销项目
 */
export async function removeOaProject(params) {
  const res = await request.post('/oa_cost_project/del', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除报销项目
 */
export async function addOaProject(params) {
  const res = await request.post('/oa_cost_project/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除报销项目
 */
export async function updateOaProject(params) {
  const res = await request.post('/oa_cost_project/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}

/**
 * 报销分类
 */
export async function pageOaCate(params) {
  const res = await request.post('/oa_cost_category/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除分类
 */
export async function removeOaCate(params) {
  const res = await request.post('/oa_cost_category/del', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除分类
 */
export async function addOaCate(params) {
  const res = await request.post('/oa_cost_category/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除分类
 */
export async function updateOaCate(params) {
  const res = await request.post('/oa_cost_category/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 报销申请列表
 */
export async function pageOaCost(params) {
  if (params.startDate === null) params.startDate = '';
  if (params.endDate === null) params.endDate = '';
  const res = await request.post('/oa_cost/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 提交报销申请
 */
export async function addOaCost(params) {
  if (params.pay_account_bank === undefined || params.pay_account_bank === null)
    params.pay_account_bank = '';
  const res = await request.post('/oa_cost/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 审核报销申请
 */
export async function judgeOaCost(params) {
  const res = await request.post('/oa_cost/judgeCost', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 审核报销申请
 */
export async function payCost(params) {
  const res = await request.post('/oa_cost/payCost', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 导出报销申请列表
 */
export async function exportOaCostList(params) {
  const res = await request.post('/oa_cost/exportExcel', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除报销申请
 */
export async function delOaCost(params) {
  const res = await request.post('/oa_cost/del', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 用户的常用报销账号列表
 */
export async function pageAdminAccount(params) {
  const res = await request.post('/admin_account/getListByAdminId', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 添加报销账号
 */
export async function addAdminAccount(params) {
  const res = await request.post('/admin_account/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 更新报销账号
 */
export async function updateAdminAccount(params) {
  const res = await request.post('/admin_account/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除报销账号
 */
export async function removeAdminAccount(params) {
  const res = await request.post('/admin_account/del', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 添加编辑学生标签
 */
export async function updateStudentTags(params) {
  const res = await request.post('/student_tags/update', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 删除学生标签
 */
export async function removeStudentTags(params) {
  const res = await request.post('/student_tags/del', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
/**
 * 学生标签列表
 */
export async function pageStudentTags(params) {
  const res = await request.post('/student_tags/getList', params);
  if (res.data.code === 20000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.data));
}
